import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
// 自动导入组件插件
import components from 'unplugin-vue-components/vite';
// 自动导入模块
import autoImport from 'unplugin-auto-import/vite';

// https://vitejs.dev/config/
export default defineConfig({
	plugins: [
		vue(),
		components({
			dirs: ['src/components'],
			extensions: ['vue'],
		}),
		autoImport({
			imports: ['vue', 'vue-router'],
		}),
	],
	resolve: {
		alias: {
			// 设置别名
			'@': path.resolve(__dirname, './src'),
			vue: 'vue/dist/vue.esm-bundler.js',
		},
	},
	server: {
		port: 3000,
		proxy: {
			'/shop': {
				target: 'http://fast.isxin.top/shop/',
				// target: 'http://www.myfast.com/shop/',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/shop/, ''),
			},
		}
	},
});
